package com.taxshare.purchaser.controller;

import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.purchaser.entity.InvoiceCollectionEntity;
import com.taxshare.purchaser.entity.InvoiceDetailEntity;
import com.taxshare.purchaser.service.InvoiceCollectionService;
import com.taxshare.purchaser.view.dto.HandEnterDTO;
import com.taxshare.purchaser.view.dto.InvoiceCollectionDTO;
import com.taxshare.purchaser.view.dto.InvoiceCollectionQueryAllDTO;
import com.taxshare.purchaser.view.dto.InvoiceImageDTO;
import com.taxshare.purchaser.view.vo.InvoiceCollectionQueryAllVO;
import com.taxshare.response.beans.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @author YANG
 * @date 2021/4/2
 */
@RestController
@RequestMapping("/invoiceCollection")
@Api(tags = "增值税发票采集")
public class InvoiceCollectionController {

    @Autowired
    InvoiceCollectionService invoiceCollectionService;

    @PostMapping("/query")
    @ApiOperation(value = "发票采集信息查询", notes = "发票采集")
    public Response<InvoiceCollectionEntity> invoiceCollectionQuery(@RequestBody PageRequest<InvoiceCollectionDTO> query) {
        return invoiceCollectionService.invoiceCollectionQuery(query);
    }

    @PostMapping("/queryDetail")
    @ApiOperation(value = "发票明细查询", notes = "发票采集")
    public Response<InvoiceDetailEntity> invoiceDetailQuery(@RequestBody PageRequest<InvoiceCollectionDTO> query) {
        return invoiceCollectionService.invoiceDetailQuery(query);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "发票删除", notes = "发票采集")
    public Response invoiceDelete(@RequestBody InvoiceCollectionDTO invoiceCollectionDTO) {
        return invoiceCollectionService.invoiceDelete(invoiceCollectionDTO);
    }

    @PostMapping("/handEnter")
    @ApiOperation(value = "手工录入", notes = "发票采集")
    public Response handEnter(@RequestBody HandEnterDTO handEnterDTO) {
        return invoiceCollectionService.handEnter(handEnterDTO);
    }

    @PostMapping("/invoiceCheck")
    @ApiOperation(value = "发票查验", notes = "发票采集")
    public Response invoiceCheck(@RequestBody HandEnterDTO handEnterDTO) {
        return invoiceCollectionService.invoiceCheck(handEnterDTO);
    }

    @ApiOperation(value = "上传图片识别", notes = "发票采集")
    @PostMapping("/uploadInvoiceImage")
    public Response uploadInvoiceImage(@RequestParam("files") List<MultipartFile> multipartFiles,@RequestParam("mark") String mark) throws Exception {
        return invoiceCollectionService.uploadInvoiceImage(multipartFiles,mark);
    }

    @PostMapping("/submit")
    @ApiOperation(value = "提交报销", notes = "未报销")
    public Response submitReimbursement(@RequestBody InvoiceCollectionDTO invoiceCollectionDTO) {
        return invoiceCollectionService.submitReimbursement(invoiceCollectionDTO);
    }

    @PostMapping("/personLiable")
    @ApiOperation(value = "责任人、记账科目、授权报销设置", notes = "未报销")
    public Response personLiable(@RequestBody InvoiceCollectionDTO invoiceCollectionDTO) {
        return invoiceCollectionService.personLiable(invoiceCollectionDTO);
    }

    @PostMapping("/applicationRejected")
    @ApiOperation(value = "申请驳回", notes = "已报销")
    public Response applicationRejected(@RequestBody InvoiceCollectionDTO invoiceCollectionDTO) {
        return invoiceCollectionService.applicationRejected(invoiceCollectionDTO);
    }

    @GetMapping("/getInvoiceImage")
    @ApiOperation(value = "发票影像查询", notes = "发票采集")
    public Response getInvoiceImage(InvoiceImageDTO invoiceImageDTO) throws Exception {
        return invoiceCollectionService.getInvoiceImage(invoiceImageDTO);
    }

    @PostMapping("/queryAll")
    @ApiOperation(value = "查询所有发票信息", notes = "发票采集")
    public Response<InvoiceCollectionQueryAllVO> invoiceCollectionQueryAll(@RequestBody PageRequest<InvoiceCollectionQueryAllDTO> query) {
        return invoiceCollectionService.invoiceCollectionQueryAll(query);
    }

    @PostMapping("/submitToPool")
    @ApiOperation(value = "提交至发票池(对公)", notes = "发票采集")
    public Response submitToPool(@RequestBody InvoiceCollectionDTO invoiceCollectionDTO) {
        return invoiceCollectionService.submitToPool(invoiceCollectionDTO);
    }

    @PostMapping("/queryByMark")
    @ApiOperation(value = "发票采集信息查询（对公）", notes = "发票采集")
    public Response<InvoiceCollectionEntity> queryByMark(@RequestBody PageRequest<InvoiceCollectionDTO> query) {
        return invoiceCollectionService.queryByMark(query);
    }

}
